/*
 * properties.h
 *
 *  Created on: Dec 21, 2010
 *      Author: fify
 */

#ifndef PROPERTIES_H_
#define PROPERTIES_H_

#include <map>
#include <string>

namespace CncrJConfig
{

class Properties
{
public:
	std::map<std::string, std::string> * propmap;

private:
	Properties();

public:
	virtual ~Properties();

	int load_properties(const char *file, char delimiter = '=', bool verbose = false, bool multiline = false);
	int load_properties(std::istream &ist, char delimiter = '=', bool verbose = false, bool multiline =false);
	void set_value(const std::string key, const std::string value);

	// 删除字符串首尾空白：\t \r \n
	std::string remove_LT_spaces(std::string str);

	std::string get_value(std::string key, std::string def) const;
	const char* get_value(std::string key, const char* def) const;
	int get_value(std::string key, int def);
	long get_value(std::string key, long def);
	long long get_value(std::string key, long long def);
	double get_value(std::string key, double def);
;
	void get_list(std::string &outBuf, std::string linePrefix) const;
	static Properties * get_instance();
};

} // End of namespace.

#endif /* PROPERTIES_H_ */
